package jp.sinya.temicontact;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * @author Koizumi Sinya
 * @date 2018/01/11. 21:20
 * @edithor
 * @date
 */
public class SplashFragment extends Fragment {
    private SplashCallback splashCallback;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_splash, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        getActivity().getWindow().getDecorView().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (splashCallback != null) {
                    splashCallback.finishCallback();
                }
            }
        }, 2000);
    }

    public void setSplashCallback(SplashCallback callback) {
        this.splashCallback = callback;
    }

    interface SplashCallback {
        void finishCallback();
    }
}
